package com.crm.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.crm.dao.UserDao;
import com.crm.entity.User;
import com.crm.mapper.UserMapper;

@Repository("userDao")
public class UserDaoImpl implements UserDao {

	@Resource(name = "userMapper")
	private UserMapper userMapper;

	public UserMapper getUserMapper() {
		return userMapper;
	}

	public void setUserMapper(UserMapper userMapper) {
		this.userMapper = userMapper;
	}

	/**
	 * 鏍规嵁鐢ㄦ埛鍚嶆煡鎵剧敤鎴峰璞�
	 * 
	 * @return User
	 */
	public User findUserByName(String username) {

		return userMapper.getUserByName(username);
	}

	@Override
	public User insertUser(User user) {
		// TODO Auto-generated method stub
		int i = userMapper.insertUser(user);
		if (i == 1) {
			return user;
		}
		return null;
	}

	public int deleteUser(int id) {		
		return userMapper.deleteUser(id);
	}

	public List<User> getAllUsers() {
		return userMapper.getAllUsers();
	}
}
